Array dump Method
Syntax
Arguments
- flagCharacter
"R" = Blank entries are eliminated in character arrays only.
Returns
- resultCharacter
Returns a CR-LF delimited list of values in the array.
Description
Create a CR-LF delimited string of a single dimensional array's contents.
Discussion
The <array>.dump() method creates a CR-LF delimited string of a single dimensional array's contents. This is the reverse of the <array>.initialize() method.
Used in conjunction with the <array>.initialize() method, this method can be used to copy one array's contents to another, or to eliminate blank entries in an array.
If flag is "R" blank entries in eliminated. This only applies to character arrays.
Examples
Assume an array "A" contains the following elements:
Element | Value |
---|---|
A[1] | Orange |
A[2] | Banana |
A[3] | Apple |
A[4] | Pineapple |
A[5] | |
A[6] | |
A[7] | |
A[8] | Mango |
dim a[8] as C a.initialize(<<%str% Orange Banana Apple Pineapple Mango %str%)
<array>.dump() will dump the values in the array. If "R" is passed in for the flag argument, the blank values in A[5], A[6], and A[7] are omitted from the output:
? A.dump() = Orange Banana Apple Pineapple Mango ' omit blank values ? A.dump("R") = Orange Banana Apple Pineapple Mango
The following script creates a new array that is a duplicate of an existing array.
dim B[A.size()] as C B.initialize(A.dump("R")) ? B = [1] = "Orange" [2] = "Banana" [3] = "Apple" [4] = "Pineapple" [5] = "Mango" [6] = "" [7] = "" [8] = ""
The following script erases the blank entries in an array.
temp = A.dump("R") A.clear(1, a.size()) ? A = [1] = "" [2] = "" [3] = "" [4] = "" [5] = "" [6] = "" [7] = "" [8] = "" A.initialize(temp) ? A = [1] = "Orange" [2] = "Banana" [3] = "Apple" [4] = "Pineapple" [5] = "Mango" [6] = "" [7] = "" [8] = ""
See Also